package jiaoti

import (
	"sync"
	"time"
)

var wg sync.WaitGroup
var chFromA = make(chan  struct{},1)
var chFromN = make(chan  struct{},1)
func Jiaoti()  {
	wg.Add(1)
	go prA()
	go prN()
	wg.Wait()
}

func prA()  {
	strABC := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	i := 0
	var str = ""
	for {
		i++
		if i==27 {
			wg.Done()
			break
		}
		str += strABC[i-1:i]
		println(strABC[i-1:i])

		chFromA<- struct{}{}
		<-chFromN

		time.Sleep(time.Millisecond*100)
	}
}

func prN()  {
	i := 0
	for {
		i++
		if i==27 {
			break
		}
		println(i)
		chFromN<- struct{}{}
		<-chFromA


		time.Sleep(time.Millisecond*100)
	}
}